package jdo.crud;

import java.io.IOException;
import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jdo.entity.Metro;
import jdo.pmf.PMF;

/**
 * Servlet implementation class ListServlet
 */
@SuppressWarnings("serial")
public class AddMetroServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
			IOException {
		PersistenceManager pm = PMF.getPersistenceManager();
		String name = request.getParameter("name");
		String ligne = request.getParameter("ligne");
		String coord_x = request.getParameter("coord_x");
		String coord_y = request.getParameter("coord_y");

		
		// Create a record
		Metro metro = new Metro(name,ligne,coord_x,coord_y);
		pm.makePersistent(metro);
		pm.close();
		response.sendRedirect("/administration.jsp?message=createdOK");
	}

}
